﻿#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    setPalette(QPalette(Qt::white));//设置窗口为白色背景
    setAutoFillBackground(true);
    this->resize(400,800);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::paintEvent(QPaintEvent *event)
{
   init();
}

void Widget::init()
{
    QPainter* painter = new QPainter(this);
    painter->setRenderHint(QPainter::Antialiasing);
    painter->setRenderHint(QPainter::TextAntialiasing);
    int w = this->width();
    int h = this->height();

    QPen pen;
    pen.setWidth(3);
    pen.setColor(Qt::red);
    pen.setStyle(Qt::SolidLine);
    pen.setCapStyle(Qt::FlatCap);
    pen.setJoinStyle(Qt::BevelJoin);

    painter->setPen(pen);

//    QBrush  brush;
//    brush.setColor(Qt::yellow); //画刷颜色
//    brush.setStyle(Qt::SolidPattern); //画刷填充样式

//    painter->setBrush(brush);

    PersonBuilder* pb = new PersonThinBuilder(painter, w, h);
    PersonDirector pd(pb);
    pd.create();

}

